package org.fuxian.service.impl;

import org.fuxian.dao.MyHouseMapper;
import org.fuxian.domain.MyHouse;
import org.fuxian.service.IMyHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyHouseServiceImpl  implements IMyHouseService {

    @Autowired
    MyHouseMapper houseMapper;

    @Override
    public List<MyHouse> findAll(Integer flag) {
        return  houseMapper.findAll(flag);
    }

    @Override
    public MyHouse findById(Integer hid) {
        return houseMapper.findById(hid);
    }

    @Override
    public int insert(MyHouse myHouse) {
        return houseMapper.add(myHouse);
    }

    public int update(MyHouse myHouse){
        return houseMapper.update(myHouse);
    }

    @Override
    public int down(Integer hid) {
        MyHouse house = new MyHouse();
        house.setHid(hid);
        house.setHflag(1);
        return houseMapper.update(house);
    }

    @Override
    public int up(Integer hid) {
        MyHouse house = new MyHouse();
        house.setHid(hid);
        house.setHflag(0);
        return houseMapper.update(house);
    }
}
